# error "XMAPPEDREGS_SHIFT doesn't match sizeof(mapped_regs_t)."
#endif
+void hlt_timer_fn(void *data)
+{
+ struct vcpu *v = data;
+ vcpu_unblock(v);
+}
+
struct vcpu *alloc_vcpu_struct(struct domain *d, unsigned int vcpu_id)
{
struct vcpu *v;
v->arch.breakimm = d->arch.breakimm;
v->arch.last_processor = INVALID_PROCESSOR;
}
+ if (!VMX_DOMAIN(v)){
+ init_timer(&v->arch.hlt_timer, hlt_timer_fn, v, v->processor);
+ }
return v;
}
get_order_from_shift(XMAPPEDREGS_SHIFT));
v->arch.privregs = NULL;
}
+ kill_timer(&v->arch.hlt_timer);
}
void free_vcpu_struct(struct vcpu *v)
}
else {
perfc_incrc(pal_halt_light);
- do_sched_op_compat(SCHEDOP_yield, 0);
+ migrate_timer(&v->arch.hlt_timer,
+ v->processor);
+ set_timer(&v->arch.hlt_timer,
+ vcpu_get_next_timer_ns(v));
+ do_sched_op_compat(SCHEDOP_block, 0);
+ stop_timer(&v->arch.hlt_timer);
}
regs->r8 = 0;
regs->r9 = 0;
unsigned long old_rsc;
int mode_flags;
fpswa_ret_t fpswa_ret; /* save return values of FPSWA emulation */
+ struct timer hlt_timer;
struct arch_vmx_struct arch_vmx; /* Virtual Machine Extensions */
#define INVALID_PROCESSOR INT_MAX
// TODO: Many (or perhaps most) of these should eventually be
// static inline functions
+#include <asm/delay.h>
#include <asm/fpu.h>
#include <asm/tlb.h>
#include <asm/ia64_int.h>
struct vcpu;
typedef struct vcpu VCPU;
typedef cpu_user_regs_t REGS;
+extern u64 cycle_to_ns(u64 cycle);
/* Note: PSCB stands for Privilegied State Communication Block. */
#define VCPU(_v,_x) (_v->arch.privregs->_x)
return (~((1UL << itir_ps(itir)) - 1));
}
+static inline s64
+vcpu_get_next_timer_ns(VCPU *vcpu)
+{
+ s64 vcpu_get_next_timer_ns;
+ u64 d = PSCBX(vcpu, domain_itm);
+ u64 now = ia64_get_itc();
+
+ if (d > now)
+ vcpu_get_next_timer_ns = cycle_to_ns(d - now) + NOW();
+ else
+ vcpu_get_next_timer_ns = cycle_to_ns(local_cpu_data->itm_delta) + NOW();
+
+ return vcpu_get_next_timer_ns;
+}
+
#define verbose(a...) do {if (vcpu_verbose) printf(a);} while(0)
//#define vcpu_quick_region_check(_tr_regions,_ifa) 1